<template>
	<view>

		<!-- 详情 -->
		<view class="description">
			<view class="title"><rich-text :nodes="carData.detail"></rich-text></view>
		</view>
		<button class="register_submit" @click="register_submit">添加车辆</button>
	</view>
</template>

<script>
import uniList from '@/components/uni-list/uni-list.vue'
	import uniListItem from '@/components/uni-list-item/uni-list-item.vue'
	export default {
		components: {
			uniList,
			uniListItem
		},
	data() {
		return {
			//session
			sessionid:'',
			hearder:'',
			//商品描述html
			carData: {
				detail: '',
				factory_name: '选择',
				brand_name: '选择',
				vehicle_name: '选择',
				year_name: '选择',
				factory_id: '',
				brand_id: '',
				vehicle_id: '',
				year_id: ''
			},
			factory_select:[{name:'奥迪',next:true,dataid:'1'},{name:'宝马',next:true,dataid:'2'},],
			brand_select:[],
			vehicle_select:[],
			year_select:[],
		};
	},
	onShow() {


	},
	onLoad(e) {
		console.debug(e);
		this.carData.year_id = e.id;
		this.loadFactoryList();
	},
	methods: {
		register_submit: function() {
			//var indexNav = this.$SysCache.get('app_car_factorylist');
			var indexNav =false;
			if (indexNav) {
				this.car_list = indexNav;
			} else {
				this.sessionid = uni.getStorageSync("sessionid");
				this.hearder = uni.getStorageSync("hearder");
				if (this.sessionid == null||this.sessionid == ''){
					uni.showToast({title: "请先登录！"});
					return;
				}
				var header = this.hearder;
				var sessionid = this.sessionid;
				var data = {};
				this.$Request.post(this.$api.car.addCar + '?car_id='+this.carData.year_id,data,header+sessionid).then(res => {


					if (res.code == 200) {
						uni.switchTab({url:'../tabBar/user/user'});
						//uni.showToast("绑定成功");

						/*
						{"car_type_name":"帝豪","path":"1","level":1,"spells_code":"D","parent_id":1,"id":36026}
						*/
						//this.car_list = res.data;
						//this.$SysCache.put("app_car_factorylist",res.data,86400);
					}
				});
			}
		},
		loadFactoryList: function() {
			//var indexNav = this.$SysCache.get("app_car_factorylist");
			var indexNav =false;
			if(indexNav){
				this.factory_select = indexNav;
			}else{
				this.$Request.post(this.$api.car.queryCarDetail+"?id="+this.carData.year_id).then(res => {

					if (res.code == 200) {
						/*
						{"car_type_name":"帝豪","path":"1","level":1,"spells_code":"D","parent_id":1,"id":36026}
						*/
						this.carData.detail = res.data.carTypeName;
						//this.$SysCache.put("app_car_factorylist",res.data,86400);
					}
				})
			}
		},
		chooseFactory:function(e){

			console.log('picker发送选择改变，携带值为', e)
			//this.index = e.target.value
			//this.vehicle_select = data
		},
	}
};
</script>

<style lang="scss">
page {
	background-color: #f8f8f8;
}

.description {
	.title {
		width: 100%;
		height: 80upx;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 26upx;
		color: #999;
	}
}

</style>
